package com.searchanything;

import com.commonfunction.CommFunction;
import com.databasefunction.AllDBFunction;
import com.databasefunction.DatabaseConstants;
import com.menu.Constants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class SavenSubmitInfo extends ActionSupport{
	//Criticle bsiness Date;
	private String barcode,brockername,customername,commitionagent,businessRSTNo,businessVehicleNo,businessCommodity,businessNoOfBags,businessPONo,businessGrossWeight,businessTareWeight,businessNetWeight,businessdate;
	private String businessRate,businessGrossAmount,businessLessRebate,businesscashDiscount,businessAdvance,businessTotalRebate,businessTotalPaid,businessWeighingMachineUser,businessLabUser;
	private String businessDamageSeeds,businessSandSilica,businessMoisture,businessExcessDamage,businessExcessSandSilica,businessExcessMoisture,businessDamageAmountCut,businessSandSilicaAmountCut,businessMoistureAmountCut,businessUnloading,businessAddDalali;
	private String systime,address;
	
	public String getSystime() {
		return systime;
	}

	public void setSystime(String systime) {
		this.systime = systime;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getBarcode() {
		return barcode;
	}

	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}

	public String getBrockername() {
		return brockername;
	}

	public void setBrockername(String brockername) {
		this.brockername = brockername;
	}

	public String getCustomername() {
		return customername;
	}

	public void setCustomername(String customername) {
		this.customername = customername;
	}

	public String getCommitionagent() {
		return commitionagent;
	}

	public void setCommitionagent(String commitionagent) {
		this.commitionagent = commitionagent;
	}

	public String getBusinessRSTNo() {
		return businessRSTNo;
	}

	public void setBusinessRSTNo(String businessRSTNo) {
		this.businessRSTNo = businessRSTNo;
	}

	public String getBusinessVehicleNo() {
		return businessVehicleNo;
	}

	public void setBusinessVehicleNo(String businessVehicleNo) {
		this.businessVehicleNo = businessVehicleNo;
	}

	public String getBusinessCommodity() {
		return businessCommodity;
	}

	public void setBusinessCommodity(String businessCommodity) {
		this.businessCommodity = businessCommodity;
	}

	public String getBusinessNoOfBags() {
		return businessNoOfBags;
	}

	public void setBusinessNoOfBags(String businessNoOfBags) {
		this.businessNoOfBags = businessNoOfBags;
	}

	public String getBusinessPONo() {
		return businessPONo;
	}

	public void setBusinessPONo(String businessPONo) {
		this.businessPONo = businessPONo;
	}

	public String getBusinessGrossWeight() {
		return businessGrossWeight;
	}

	public void setBusinessGrossWeight(String businessGrossWeight) {
		this.businessGrossWeight = businessGrossWeight;
	}

	public String getBusinessTareWeight() {
		return businessTareWeight;
	}

	public void setBusinessTareWeight(String businessTareWeight) {
		this.businessTareWeight = businessTareWeight;
	}

	public String getBusinessNetWeight() {
		return businessNetWeight;
	}

	public void setBusinessNetWeight(String businessNetWeight) {
		this.businessNetWeight = businessNetWeight;
	}

	public String getBusinessdate() {
		return businessdate;
	}

	public void setBusinessdate(String businessdate) {
		this.businessdate = businessdate;
	}

	public String getBusinessRate() {
		return businessRate;
	}

	public void setBusinessRate(String businessRate) {
		this.businessRate = businessRate;
	}

	public String getBusinessGrossAmount() {
		return businessGrossAmount;
	}

	public void setBusinessGrossAmount(String businessGrossAmount) {
		this.businessGrossAmount = businessGrossAmount;
	}

	public String getBusinessLessRebate() {
		return businessLessRebate;
	}

	public void setBusinessLessRebate(String businessLessRebate) {
		this.businessLessRebate = businessLessRebate;
	}

	public String getBusinesscashDiscount() {
		return businesscashDiscount;
	}

	public void setBusinesscashDiscount(String businesscashDiscount) {
		this.businesscashDiscount = businesscashDiscount;
	}

	public String getBusinessAdvance() {
		return businessAdvance;
	}

	public void setBusinessAdvance(String businessAdvance) {
		this.businessAdvance = businessAdvance;
	}

	public String getBusinessTotalRebate() {
		return businessTotalRebate;
	}

	public void setBusinessTotalRebate(String businessTotalRebate) {
		this.businessTotalRebate = businessTotalRebate;
	}

	public String getBusinessTotalPaid() {
		return businessTotalPaid;
	}

	public void setBusinessTotalPaid(String businessTotalPaid) {
		this.businessTotalPaid = businessTotalPaid;
	}

	public String getBusinessWeighingMachineUser() {
		return businessWeighingMachineUser;
	}

	public void setBusinessWeighingMachineUser(String businessWeighingMachineUser) {
		this.businessWeighingMachineUser = businessWeighingMachineUser;
	}

	public String getBusinessLabUser() {
		return businessLabUser;
	}

	public void setBusinessLabUser(String businessLabUser) {
		this.businessLabUser = businessLabUser;
	}

	public String getBusinessDamageSeeds() {
		return businessDamageSeeds;
	}

	public void setBusinessDamageSeeds(String businessDamageSeeds) {
		this.businessDamageSeeds = businessDamageSeeds;
	}

	public String getBusinessSandSilica() {
		return businessSandSilica;
	}

	public void setBusinessSandSilica(String businessSandSilica) {
		this.businessSandSilica = businessSandSilica;
	}

	public String getBusinessMoisture() {
		return businessMoisture;
	}

	public void setBusinessMoisture(String businessMoisture) {
		this.businessMoisture = businessMoisture;
	}

	public String getBusinessExcessDamage() {
		return businessExcessDamage;
	}

	public void setBusinessExcessDamage(String businessExcessDamage) {
		this.businessExcessDamage = businessExcessDamage;
	}

	public String getBusinessExcessSandSilica() {
		return businessExcessSandSilica;
	}

	public void setBusinessExcessSandSilica(String businessExcessSandSilica) {
		this.businessExcessSandSilica = businessExcessSandSilica;
	}

	public String getBusinessExcessMoisture() {
		return businessExcessMoisture;
	}

	public void setBusinessExcessMoisture(String businessExcessMoisture) {
		this.businessExcessMoisture = businessExcessMoisture;
	}

	public String getBusinessDamageAmountCut() {
		return businessDamageAmountCut;
	}

	public void setBusinessDamageAmountCut(String businessDamageAmountCut) {
		this.businessDamageAmountCut = businessDamageAmountCut;
	}

	public String getBusinessSandSilicaAmountCut() {
		return businessSandSilicaAmountCut;
	}

	public void setBusinessSandSilicaAmountCut(String businessSandSilicaAmountCut) {
		this.businessSandSilicaAmountCut = businessSandSilicaAmountCut;
	}

	public String getBusinessMoistureAmountCut() {
		return businessMoistureAmountCut;
	}

	public void setBusinessMoistureAmountCut(String businessMoistureAmountCut) {
		this.businessMoistureAmountCut = businessMoistureAmountCut;
	}

	public String getBusinessUnloading() {
		return businessUnloading;
	}

	public void setBusinessUnloading(String businessUnloading) {
		this.businessUnloading = businessUnloading;
	}

	public String getBusinessAddDalali() {
		return businessAddDalali;
	}

	public void setBusinessAddDalali(String businessAddDalali) {
		this.businessAddDalali = businessAddDalali;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		AllDBFunction allDBFunction = new AllDBFunction();
		CommFunction commFunction = new CommFunction();
		String userrole = (String) ActionContext.getContext().getSession().get("userrole"); 
		if ((null != userrole) && ( userrole.equals("admin") || userrole.equals("superadmin"))) {
			int date = commFunction.formatDateForDb(businessdate);
			
			allDBFunction.update(barcode, brockername, customername, commitionagent, businessRSTNo, businessVehicleNo, businessCommodity, businessNoOfBags, businessPONo, businessGrossWeight, businessTareWeight, businessNetWeight, date, businessRate, businessGrossAmount, businessLessRebate, businesscashDiscount, businessAdvance, businessTotalRebate, businessTotalPaid, businessWeighingMachineUser, businessLabUser, businessDamageSeeds, businessSandSilica, businessMoisture, businessExcessDamage, businessExcessSandSilica, businessExcessMoisture, businessDamageAmountCut, businessSandSilicaAmountCut, businessMoistureAmountCut, businessUnloading, businessAddDalali, "",address,systime, DatabaseConstants.operation_update);
			addActionMessage("Data Saved successfully");
			return "success";
		}else
			return "unauthorised";
	}
	
	@Override
	public void validate() {
		// TODO Auto-generated method stub
		try{
		businessNetWeight = (Integer.parseInt(businessGrossWeight.trim())-Integer.parseInt(businessTareWeight.trim()))+"";
		}catch(Exception e){
			addActionError("Please check gross weight or Tare weight");
		}
	}
	public void update(String barcode,String brockername, String customername, String commitionagent,String businessRSTNo,String businessVehicle, String businessCommodity,String businessNoOfBags,String businessPONo,String businessGrossWeight,String businessTareWeight,String businessNetWeight,
			int businessdate,String businessRate,String businessGrossAmount,String businessLessRebate,String businesscashDiscount,String businessAdvance,String businessTotalRebate,String businessTotalPaid,String businessWeighingMachineUser,
			String businessLabUser,String businessDamageSeeds,String businessSandSilica,String businessMoisture,String businessExcessDamage,String businessExcessSandSilica,String businessExcessMoisture,String businessDamageAmountCut,
			String businessSandSilicaAmountCut,String businessMoistureAmountCut,String businessUnloading,String businessAddDalali,String hide, int isupdate){
		
	}
}
